import ajax from "@/utils/request";
/**
 * 获取短信验证码
 * @param {*} mobile
 */
export const getCode = mobile => {
  return ajax(`/app/v1_0/sms/codes/${mobile}`);
};
/**
 * 用户登陆
 * @param {mobile:string,code:string} obj
 */
export const login = obj => {
  let { mobile, code } = obj;
  return ajax({
    method: "POST",
    url: "/app/v1_0/authorizations",
    data: {
      mobile,
      code
    }
  });
};
//
export const userGetInfo = () => {
  return ajax({
    method: "GET",
    url: "/app/v1_0/user/profile"
  });
};
/**
 * 获取用户自己信息
 */
export const user = () => {
  return ajax({
    method: "GET",
    url: "/app/v1_0/user"
  });
};
/**
 * 编辑用户个人资料（包含实名认证）
 * @param {object {name:''}} obj
 */
export const editProfile = obj => {
  return ajax({
    url: "/app/v1_0/user/profile",
    method: "PATCH",
    data: obj
  });
};

/**
 * 编辑用户照片资料（头像、身份证照片）
 * @param {formData} obj
 * new FormData
 */
export const upDataPhoto = obj => {
  return ajax({
    url: "/app/v1_0/user/photo",
    method: "PATCH",
    data: obj
  });
};
